<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class UserRoleRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'name' => 'required|min:2|max:15|unique:user_roles,name,' . request()->input('id'),
        ];
        return $rules;
    }

    public function messages()
    {
        return [
            'name.required' => '必须填写用户组名称！',
            'name.unique' => '用户组名称已被占用！',
            'name.min' => '用户组名称长度必须为2-15个字符！',
            'name.max' => '用户组名称长度必须为2-15个字符！',
        ];
    }

}
